#include "cblogheader.h"

CBlogHeader::CBlogHeader()
{

}

void CBlogHeader::setBlogTitle(std::string& title)
{
    this->aBlogTitle.erase();
    this->aBlogTitle += title;
}

void CBlogHeader::setBlogDate(std::string& dateTime)
{
    this->aBlogData.erase();
    this->aBlogData += dateTime;
}

void CBlogHeader::setBlogCategories(std::string &categories)
{
    this->aCategories.erase();
    this->aCategories += categories;
}

void CBlogHeader::setBlogTags(std::string &tags)
{
    this->aBlogTags.erase();
    this->aBlogTags += tags;
}

void CBlogHeader::setIsSwiper(bool isSwiper)
{
    this->isSwiper = isSwiper;
}

void CBlogHeader::setSwiperImgURL(std::string &swiperImg)
{
    this->aSwiperImgURL.erase();
    this->aSwiperImgURL += swiperImg;
}

void CBlogHeader::setIsTop(bool isTop)
{
    this->isTop = isTop;
}

void CBlogHeader::setIsToc(bool isToc)
{
    this->isToc = isToc;
}

void CBlogHeader::setIsTocOpen(bool isTocOpen)
{
    this->isTocOpen = isTocOpen;
}

void CBlogHeader::setIsComments(bool isComments)
{
    this->isComments = isComments;
}

void CBlogHeader::setBlogImgUrl(std::string &img)
{
    this->aBlogImgURL.erase();
    this->aBlogImgURL += img;
}

void CBlogHeader::setMoreText(std::string &more)
{
    this->aMore.erase();
    this->aMore += more;
}

std::string CBlogHeader::getFormatBlogHeader()
{
    string aFormatBlogHeader = "---\r\n";

    // title
    aFormatBlogHeader += "title: " + this->aBlogTitle + "\r\n";
    // data
    aFormatBlogHeader += "date: " + this->aBlogData + "\r\n";

    // categories
    aFormatBlogHeader += "categories: [" + this->aCategories + "]\r\n";

    // tags
    aFormatBlogHeader += "tags: [" + this->aBlogTags + "]\r\n";

    // swiper
    aFormatBlogHeader += "swiper: " + (string)(this->isSwiper ? "true" : "false") + "\r\n";

    // swiperImg
    aFormatBlogHeader += "swiperImg: '" + this->aSwiperImgURL  + "'\r\n";

    // top
    aFormatBlogHeader += "top: " + (string)(this->isTop ? "true" : "false")  + "\r\n";

    // top
    aFormatBlogHeader += "toc: " + (string)(this->isToc ? "true" : "false")  + "\r\n";

    // topOpen
    aFormatBlogHeader += "tocOpen: " + (string)(this->isTocOpen ? "true" : "false")  + "\r\n";

    // comments
    aFormatBlogHeader += "comments: " + (string)(this->isComments ? "true" : "false")  + "\r\n";

    // img
    aFormatBlogHeader += "img: '" + this->aBlogImgURL + "'\r\n";

    aFormatBlogHeader += "---\r\n\r\n";

    aFormatBlogHeader += this->aMore;

    aFormatBlogHeader += "\r\n<!--more-->\r\n";
    return aFormatBlogHeader;
};
